package juc.threadcore;

public class SleepDontReleasemonitor implements Runnable {
    public static void main(String[] args) {
        SleepDontReleasemonitor sleepDontReleasemonitor = new SleepDontReleasemonitor();
        new Thread(sleepDontReleasemonitor).start();
        new Thread(sleepDontReleasemonitor).start();
    }

    @Override
    public void run() {
        syn();
    }

    private synchronized void syn() {
        System.out.println("线程" + Thread.currentThread().getName() + "获得了monitor锁");
        try {
            Thread.sleep(400);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("线程" + Thread.currentThread().getName() + "完成了任务");
    }
}
